package com.example.ordersys.controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:咭咭熊
 * Date:2021 - 07 - 31
 * Time:21:59
 */

import com.example.ordersys.mapper.DishMapper;
import com.example.ordersys.model.Dish;
import com.example.ordersys.tools.ResponseBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/***
 * 菜单列表
 */
@RestController
@RequestMapping("/dish")
public class DishController {

    @Resource
    private DishMapper dishMaper;

    /***
     * 1.获取菜单列表
     * @return
     */
    @RequestMapping("/list")
    public ResponseBody<List<Dish>> getList(){
        List<Dish>  data = dishMaper.getList();
        return new ResponseBody<>(0,"",data);
    }

    /***
     * 2.管理员添加菜品
     * @return
     */
    @RequestMapping("/add")
    public ResponseBody<Integer> add(Dish dish){
        int data = 0;
        data = dishMaper.add(dish);
        return  new ResponseBody<>(0,"",data);
    }

    /***
     * 2.管理员删除菜品
     * @param id
     * @return
     */
    @RequestMapping("/del")
    public ResponseBody<Integer> del(int id){
        int data = dishMaper.del(id);
        return new ResponseBody<>(0,"",data);
    }
}
